package com.anzia.study_1.slice;

import com.anzia.study_1.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.Text;

public class AbilitySlice1 extends AbilitySlice {

	@Override
	protected void onStart(Intent intent) {
		super.onStart(intent);

		// 指定加载的页面（Java、xml）
		super.setUIContent(ResourceTable.Layout_ability1);

		Text text = (Text) findComponentById(ResourceTable.Id_text1);

		if (intent != null) {
			String user = intent.getStringParam("user");
			text.append(", " + user);
		}

		text.setClickedListener(component -> {
			// 返回值
			Intent intent1 = new Intent();
			intent1.setParam("pwd", "123456");
			setResult(intent1);
			// 关闭本AbilitySlice1，返回上一页
			terminate();
		});

	}
}
